package com.zhan.drugStore.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhan.drugStore.bean.entity.Bill;
import com.zhan.drugStore.bean.entity.Customer;
import com.zhan.drugStore.bean.vo.BillVO;
import com.zhan.drugStore.service.CustomerService;
import com.zhan.drugStore.util.BeanUtils;
import com.zhan.drugStore.util.ResponseBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zy
 * @since 2024-06-08
 */
@RestController
@RequestMapping("/customer")
public class CustomerController extends SuperController{

    @Resource
    private CustomerService customerService;

    @ApiOperation("/根据名称获取客户")
    @GetMapping("/getCustomerByName")
    public ResponseBean<Customer> getCustomerByName(@RequestParam String name) {
        LambdaQueryWrapper<Customer> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Customer::getCustomerName,name).last("limit 1");
        return super.resultSuccess(customerService.getOne(wrapper));
    }

}

